package com.xu.consumer.controller;

import com.xu.dto.CardDto;
import com.xu.service.CardService;
import com.xu.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

/**
 * @author 徐老板
 * @date 2020/3/31   13:45
 */
@Api(value = "操作名片",tags = "操作名片")
@RestController
@CrossOrigin//这个是spring提供的解决跨域问题的注解
public class CardController {

    @Reference(version = "1.0.0",timeout = 10000,retries = 0)
    private CardService cardService;

    //校验
    @ApiOperation(value = "实现手机号校验",notes = "实现手机号校验")
    @GetMapping("/api/card/checkphone.do")
    public R check(String phone){
        return cardService.checkPhone(phone);
    }

    //查询单个详情
    @ApiOperation(value = "查询单个名片信息",notes = "查询单个名片信息")
    @GetMapping("/api/card/single.do")
    public R single(String phone){
        return cardService.queryByPhone(phone);
    }

    //查询单个详情
    @ApiOperation(value = "查询单个名片信息对应的二维码",notes = "查询单个名片信息对应的二维码")
    @GetMapping("/api/card/singleQrcode.do")
    public R singleQrcode(String phone){
        return cardService.queryByPhone(phone);
    }

    //查询全部
    @ApiOperation(value = "查询所有名片数据",notes = "查询所有名片数据")
    @PostMapping("/api/card/all.do")
    public R all(){
        return cardService.all();
    }

    //新增名片
    @ApiOperation(value = "新增名片数据",notes = "新增名片数据")
    @PostMapping("/api/card/save.do")
    public R save(@RequestBody CardDto cardDto){
        return cardService.save(cardDto);
    }

}
